package com.ruoyi.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.FormSettingBig;
import com.ruoyi.manage.service.IFormSettingBigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 清单大项Controller
 * 
 * @author zww
 * @date 2025-07-14
 */
@Api
@RestController
@RequestMapping("/manage/formsettingbig")
public class FormSettingBigController extends BaseController
{
    @Autowired
    private IFormSettingBigService formSettingBigService;

    /**
     * 查询清单大项列表
     */
    @PreAuthorize("@ss.hasPermi('manage:formsettingbig:list')")
    @GetMapping("/list")
    public TableDataInfo list(FormSettingBig formSettingBig)
    {
        startPage();
        List<FormSettingBig> list = formSettingBigService.selectFormSettingBigList(formSettingBig);
        return getDataTable(list);
    }

    /**
     * 导出清单大项列表
     */
    @PreAuthorize("@ss.hasPermi('manage:formsettingbig:export')")
    @Log(title = "清单大项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FormSettingBig formSettingBig)
    {
        List<FormSettingBig> list = formSettingBigService.selectFormSettingBigList(formSettingBig);
        ExcelUtil<FormSettingBig> util = new ExcelUtil<FormSettingBig>(FormSettingBig.class);
        util.exportExcel(response, list, "清单大项数据");
    }

    /**
     * 获取清单大项详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:formsettingbig:query')")
    @GetMapping(value = "/{formSettingBigId}")
    public AjaxResult getInfo(@PathVariable("formSettingBigId") Long formSettingBigId)
    {
        return success(formSettingBigService.selectFormSettingBigByFormSettingBigId(formSettingBigId));
    }

    /**
     * 新增清单大项
     */
    @PreAuthorize("@ss.hasPermi('manage:formsettingbig:add')")
    @Log(title = "清单大项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FormSettingBig formSettingBig)
    {
        formSettingBig.setCreateBy(getUsername());
        return toAjax(formSettingBigService.insertFormSettingBig(formSettingBig));
    }

    /**
     * 修改清单大项
     */
    @PreAuthorize("@ss.hasPermi('manage:formsettingbig:edit')")
    @Log(title = "清单大项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FormSettingBig formSettingBig)
    {
        formSettingBig.setUpdateBy(getUsername());
        return toAjax(formSettingBigService.updateFormSettingBig(formSettingBig));
    }

    /**
     * 删除清单大项
     */
    @PreAuthorize("@ss.hasPermi('manage:formsettingbig:remove')")
    @Log(title = "清单大项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{formSettingBigIds}")
    public AjaxResult remove(@PathVariable Long[] formSettingBigIds)
    {
        return toAjax(formSettingBigService.deleteFormSettingBigByFormSettingBigIds(formSettingBigIds));
    }
}
